package com.systop.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.systop.validator.group.AddGroup;
import com.systop.validator.group.UpdateGroup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Null;

@Data
@NoArgsConstructor
@AllArgsConstructor
@TableName("goods_stock")
public class GoodsStock {
  /**
   * 库存唯一ID
   */
  @TableId(type = IdType.INPUT)
  @Null(groups = {AddGroup.class, UpdateGroup.class},message = "库存ID不可用")
  private Long stockId;
  /**
   * 商品ID
   */
  @NotNull(groups = {AddGroup.class,UpdateGroup.class},message = "必须指定商品ID")
  private Long goodsId;
  /**
   * 库存数量
   */
  @NotNull(groups = {AddGroup.class,UpdateGroup.class},message = "必须指定库存数量")
  @Min(value = 0,groups = {AddGroup.class,UpdateGroup.class},message = "库存数量不能小于0")
  private Integer stockNum;
  /**
   * 锁定库存数量
   */
  @Min(value = 0,groups = {AddGroup.class,UpdateGroup.class},message = "锁定数量不能小于0")
  private Integer lockStockNum;
}
